package business.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Required;
import org.springframework.transaction.annotation.Transactional;

import vo.Opinion;
import vo.Sentence;
import business.OpinionService;
import dao.OpinionDAO;

public class OpinionServiceImpl implements OpinionService {

	private OpinionDAO opinionDao;

	public List<Opinion> getAll() {
		return opinionDao.findAll();
	}

	@Required
	public void setOpinionDao(OpinionDAO opinionDao) {
		this.opinionDao = opinionDao;
	}

	@Transactional
	public void insertOpinion(Opinion op) {
		opinionDao.create(op);
	}

	public List<Opinion> getAll(int start, int pageSize) {
		return opinionDao.findAll(start, pageSize);
	}

	public long getTotalCount() {
		return opinionDao.findTotalCount();
	}

	public List<Opinion> getByPaperId(int start, int pageSize, long paperId) {
		return opinionDao.findByPaperId(start, pageSize, paperId);
	}

	public long getTotalCountByPaperId(long paperId) {
		return opinionDao.findTotalCountByPaperId(paperId);
	}

	// 按照类别分类
	public List<Opinion> getByType(int start, int pageSize, long type) {
		return opinionDao.findByType(start, pageSize, type);
	}

	public long getTotalCountByType(long type) {
		return opinionDao.findTotalCountByType(type);
	}

	// 按照关键字分类
	public List<Opinion> getByKeyword(int start, int pageSize, String keyword) {
		return opinionDao.findByKeyword(start, pageSize, keyword);
	}

	public long getTotalCountByKeyword(String keyword) {
		return opinionDao.findTotalCountByKeyword(keyword);
	}

	// 按照type,关键字分类
	public List<Opinion> getByTypeKeyword(int start, int pageSize, long type,String keyword) {
		return opinionDao.findByTypeKeyword(start, pageSize, type,keyword);
	}

	public long getTotalCountByTypeKeyword(long type,String keyword) {
		return opinionDao.findTotalCountByTypeKeyword(type,keyword);
	}

}